using System;
using System.Collections.Generic;
using Dict.DataModel;

namespace Dict.Dao
{
    public class TableYuanDao:DaoBase<TableYuan>
    {
        public override void AddPrimaryIndex(TableYuan model)
        {
            cachePrimary[model.id.ToString()] = model;
        }

        public override string GetFileName()
        {
            return "TableYuan.txt";
        }

        protected override TableYuan ParseRowData(string[] rowData)
        {
            TableYuan data = new TableYuan();
			data.id = rowData [0];
			data.yuanName = rowData [1];
			data.heroId = rowData [2];

            if (string.IsNullOrEmpty(rowData[3]))
            {
                data.type = 0;
            }
            else
            {
                data.type = int.Parse(rowData[3]);
            }
			data.hero0 = rowData [4];
			data.hero1 = rowData [5];
			data.hero2 = rowData [6];
			data.hero3 = rowData [7];
			data.equip0 = rowData [8];
			data.treaId0 = rowData [9];

            if (string.IsNullOrEmpty(rowData[10]))
            {
                data.perhp = 0;
            }
            else
            {
                data.perhp = double.Parse(rowData[10]);
            }

            if (string.IsNullOrEmpty(rowData[11]))
            {
                data.peratt = 0;
            }
            else
            {
                data.peratt = double.Parse(rowData[11]);
            }

            if (string.IsNullOrEmpty(rowData[12]))
            {
                data.perdef = 0;
            }
            else
            {
                data.perdef = double.Parse(rowData[12]);
            }

            return data;
        }


        public override void AddOneIndex(TableYuan model)
        {
            if (!cacheOneIndex.ContainsKey(model.heroId.ToString()))
            {
                cacheOneIndex[model.heroId.ToString()] = new List<TableYuan>();
            }
            cacheOneIndex[model.heroId.ToString()].Add(model);
        }
    

    }

}
